<template>
	<view class="harvestAddressList">
		<!-- 顶部蒙层 -->
		<view class="topBack"></view>
		<!-- 中间菜单 -->
		<view class="bottomBack">
			<view class="harvestAddressDiv" v-for="(item,index) in addressList" :key="index" @tap="activeAddress(item)">
				<view class="harvestAddressItem">
					<view class="itemLeft">
						<image class="itemImg" :src="item.head"></image>
						<view class="itemLeftRight">
							<text class="itemLeftRightTop">{{item.address_name}}{{item.address_details}}</text>
							<text class="itemLeftRightBottom">{{item.consignee}} {{item.phone}}</text>
						</view>
					</view>
					<view class="itemRight" @click.stop.prevent="edisAdressPage(item)">
						<image class="bi"
							src="https://chongwu.aitaoba.net/storage/uploads/20231118/c0f7b4ec52f54c747f58363ac24fbc66.png">
						</image>
						<!-- 	<view class="itemRightBottom" @click.stop="activeFun(index)">
							<view class="itemRadio">
								<view class="activeRadio" v-if="activeIndex==index"></view>
							</view>
							<text class="radioText">设置默认</text>
						</view> -->
					</view>


				</view>
				<view class="gang"></view>
			</view>
		</view>
		<!-- 底部按钮 -->
		<view class="bottomDiv">
			<button class="addAdressButton" @tap="addAdressButton">新增收货地址</button>
		</view>
	</view>
</template>

<script>
	import {
		addressList
	} from '@/api/my.js'
	export default {
		components: {

		},
		data() {
			return {
				value: 0,
				harvestAddressList: [{
					shdz: '重庆市红旗河沟天星大楼16-9',
					name: '张三娃',
					tel: '15689784523'
				}, {
					shdz: '重庆市红旗河沟天星大楼16-9',
					name: '张三娃',
					tel: '15689784523'
				}, {
					shdz: '重庆市红旗河沟天星大楼16-9',
					name: '张三娃',
					tel: '15689784523'
				}, ],
				activeIndex: 0,
				addressList: [],
			};
		},

		/**
		 * 跳转到个人中心
		 */
		onBackPress(e) {

		},
		onPullDownRefresh() {

		},
		onShow() {
			this.getHarvestAddressList()
		},

		onLoad(options) {

		},

		watch: {

		},
		methods: {
			activeAddress(item) {


				uni.$emit('addressItem', item)
				uni.navigateBack(1);
			},
			getHarvestAddressList() {
				addressList({}).then((res) => {
					console.log(res, '收货地址列表')
					this.addressList = res.data;
				}).catch((res) => {
					console.log(res, 'catch')
				})
			},
			activeFun(index) {
				this.activeIndex = index;
			},
			// 新增收货地址
			addAdressButton() {
				uni.navigateTo({
					url: "/pages/addAdress/addAdress"
				})
			},
			// 编辑收货地址
			edisAdressPage(item) {
				console.log(item, '编辑收货地址')
				uni.navigateTo({
					url: "/pages/addAdress/addAdress?item=" + encodeURIComponent(JSON.stringify(item))
				})
			},
		},
	};
</script>

<style lang="scss" scoped>
	.harvestAddressList {
		width: 100%;
		display: flex;
		flex-direction: column;
	}

	.topBack {
		width: 750rpx;
		height: 216rpx;
		background: linear-gradient(180deg, #FAE24E 0%, rgba(250, 226, 78, 0) 100%);


	}

	.bottomBack {
		width: 750rpx;
		height: 85vh;
		background: linear-gradient(180deg, #FFF5B9 0%, #FFFEF7 17%, #FFFEF7 100%);
		border-radius: 50rpx 50rpx 0rpx 0rpx;

		border: 4rpx solid #FFFFFF;
		box-sizing: border-box;
		position: fixed;
		bottom: 120rpx;
		left: 0;
		z-index: 3;
		display: flex;
		flex-direction: column;
		padding: 76rpx 36rpx 0 30rpx;
		box-sizing: border-box;
	}

	.harvestAddressDiv {
		display: flex;
		flex-direction: column;
		margin-bottom: 28rpx;
	}

	.harvestAddressItem {
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.itemLeft {
		display: flex;
		align-items: center;
	}

	.itemImg {
		min-width: 72rpx;
		min-height: 72rpx;
		max-width: 72rpx;
		max-height: 72rpx;
		background: #FAE24E;
		border-radius: 50%;
		border: 1rpx solid #683518;
	}

	.itemLeftRight {
		display: flex;
		flex-direction: column;
		margin-left: 20rpx;
	}

	.itemLeftRightTop {
		font-size: 34rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: #2E2908;
	}

	.itemLeftRightBottom {
		font-size: 30rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #797873;
		margin-top: 4rpx;
	}

	.itemRight {
		display: flex;
		flex-direction: column;
		align-items: flex-end;
	}

	.bi {
		width: 30rpx;
		height: 30rpx;
	}

	.itemRightBottom {
		display: flex;
		align-items: center;
		margin-top: 16rpx;
	}

	.itemRadio {
		min-width: 18rpx;
		min-height: 18rpx;
		background: #FFF7C4;
		border-radius: 18rpx;
		border: 1rpx solid #683518;
		display: flex;
		justify-content: center;
		align-items: center;
		box-sizing: border-box;
	}

	.activeRadio {
		min-width: 10rpx;
		min-height: 10rpx;
		border-radius: 10rpx;
		background: #FFBD05;

		border: 1rpx solid #683518;
		box-sizing: border-box;
	}

	.radioText {
		min-width: 104rpx;
		font-size: 26rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #797873;

		margin-left: 12rpx;
	}

	.bottomDiv {
		width: 750rpx;
		height: 120rpx;
		background: #FFFFFF;
		border-radius: 0rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		position: fixed;
		left: 0;
		bottom: 0;
		z-index: 3;
	}

	.addAdressButton {
		width: 690rpx;
		height: 80rpx;
		background: #FED24C;
		border-radius: 10rpx;

		border: 2rpx solid #683518;
		font-size: 28rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: #683518;
		box-sizing: border-box;
		text-align: center;
		line-height: 80rpx;
		margin: 0;
		padding: 0;
	}

	.gang {
		width: 100%;

		height: 1rpx;

		background: #D6D6D6;
		margin-top: 28rpx;
	}
</style>